package com.exam.danangtranel.Shopping;

import java.util.ArrayList;
import java.util.List;

import com.exam.danangtranel.filed.Tbshopping;
import com.example.danangtravel.DataAccess;
import com.example.danangtravel.R;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.TabHost.OnTabChangeListener;

public class Tbshopping_activity extends TabActivity implements
		OnTabChangeListener {
	public TabHost tabHost;
	public Resources res;
	public ImageButton btnhome;
	public DataAccess dataaccess;
	public static ArrayList<String> khoangcach;
	public List<Tbshopping> listshop;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tbshopping_activity);
		btnhome = (ImageButton) findViewById(R.id.btnhom);
		btnhome.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				finish();
			}
		});

		setTabs();

	}

	private void setTabs() {
		addTab("Siêu thị", R.drawable.tab_sieuthi, Tbshopping_thsieuthi.class);
		addTab("Chợ", R.drawable.tab_cho, Tbshopping_thcho.class);
		addTab("Cửa hàng", R.drawable.tab_cuahang, Tbshopping_thcuahang.class);
	}

	private void addTab(String labelId, int drawableId, Class<?> c) {
		TabHost tabHost = getTabHost();
		Intent intent = new Intent(this, c);
		TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);

		View tabIndicator = LayoutInflater.from(this).inflate(
				R.layout.tab_indicator, getTabWidget(), false);
		TextView title = (TextView) tabIndicator.findViewById(R.id.title);
		title.setText(labelId);
		ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
		icon.setImageResource(drawableId);

		spec.setIndicator(tabIndicator);
		spec.setContent(intent);
		tabHost.addTab(spec);
	}

	public void onTabChanged(String arg0) {
		// TODO Auto-generated method stub

	}

}
